@extends('layouts.system')

@section('css')
    <style type="text/css">
        .btnDiv {
            margin: 30px 0;
        }

        .btnDiv button {
            width: 90px;
            border-radius: 5px;
        }

        .tableDiv {
            padding: 20px 20px 50px 20px;
            background-color: #d7d7d7;
            width: 700px;
        }

        .tableDiv table {
            width: 400px;
        }

        .tableDiv table tr {
            background-color: #fff;
        }

        .tableDiv .des {
            text-align: right;
        }

        @media (max-width: 768px) {
            .tableDiv {
                width: 100%;
            }

            .tableDiv table {
                width: 100%;
            }
        }

    </style>
@endsection

@section('content')
    <div id="cl-wrapper" class="fixed-menu">
        <div class="container-fluid" id="pcont">
            <div class="col-md-12" style="padding-right: 0;">
                <div class="block-flat">
                    <div class="header">
                        <div class="pull-left">
                            <p class="jb_underline">提现审核&#62;&#62;提现详情</p>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    <div class="content">
                        <div class="tableDiv">
                            <table class="table-bordered">
                                <tbody>
                                <tr>
                                    <td class="des">用ID</td>
                                    <td v-text="detail.user_id"></td>
                                </tr>
                                <tr>
                                    <td class="des">用户名</td>
                                    <td v-text="detail.name"></td>
                                </tr>
                                <tr>
                                    <td class="des">提现金额</td>
                                    <td v-text="detail.cash_money"></td>
                                </tr>
                                <tr>
                                    <td class="des">申请时间</td>
                                    <td v-text="detail.created_at"></td>
                                </tr>
                                <tr>
                                    <td class="des">当前余额</td>
                                    <td v-text="detail.balance"></td>
                                </tr>
                                <tr>
                                    <td class="des">已提现金额</td>
                                    <td v-text="detail.transform_balance"></td>
                                </tr>
                                <tr>
                                    <td class="des">已结算收入</td>
                                    <td v-text="detail.transform_cash"></td>
                                </tr>
                                <tr>
                                    <td class="des">转账微信号</td>
                                    <td v-text="detail.wechat_account"></td>
                                </tr>
                                <tr>
                                    <td class="des">转账支付宝号</td>
                                    <td v-text="detail.alipay_account"></td>
                                </tr>
                                <tr>
                                    <td class="des">状态</td>
                                    <td v-text="states[detail.extract_state]"></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>

                        <div class="btnDiv">
                            <button @click='verify(2)' v-if="detail.extract_state == 1" type="button" class="btn btn-default">通过请求</button>
                            <button @click='verify(3)' v-if="detail.extract_state == 1" type="button" class="btn btn-default">否决请求</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript">

      Vue.use(VueResource)
      var vm = new Vue({
        el: '#pcont',
        data: {
          states: {},
          detail: {}
        },
        created: function () {
          getCashApplyInfo(this);
        },
        methods: {
          verify: function (state) {
            if(state == 2) {
              var msg = '是否确认通过该请求？'
            }else if(state == 3) {
              var msg = '是否确认否决该请求？'
            }
            if(confirm(msg)) {
              verify(this,state)
            }
          }
        }
      })

      //获取提现信息
      function getCashApplyInfo(_vm) {
        _vm.$http.get('/admin/task/getCashApplyInfo/{{$id}}')
          .then(function (response) {
            var json = response.body;
            if (json.state == 1) {
              _vm._data.detail = json.data.detail;
              _vm._data.states = json.data.states;
            }
          })
          .catch(function (response) {
            console.log(response)
          })
      }

      //审核
      function verify(_vm, state) {
        var data = {
          state: state
        }
        _vm.$http.post('/admin/task/verifyCashApply/{{$id}}', data, {headers: header()})
          .then(function (response) {
            var json = response.body;
            if (json.state == 1) {
              alert('该申请已处理')
              getCashApplyInfo(_vm);
            }

          })
          .catch(function (response) {
            console.log(response)
          })
      }

    </script>
@endsection